/* Copyright (c) 2011 Vitria Technology, Inc.  All rights reserved. */
package com.vitria.m3oui.rest.app.mgr;

import java.io.FileInputStream;
import java.io.IOException;

import org.restlet.representation.Representation;
import org.restlet.resource.ClientResource;
import com.qilin.hammer.util.BaseRestService;

public class AppExportTest extends BaseRestService {
	public static String APP_ID = "/sla";
    public static String APP_URL_PREFIX = URL_PREFIX + "/app.mgr/apps";
    
    public static String INSTALL_UID = "AAAAAAAA-AAAA-AAAA-AAAA-AAAAAAAAASLA";
    public static String UPGRADE_UID = "BBBBBBBB-AAAA-AAAA-AAAA-AAAAAAAAASLA";
    public static String EXPORT_UID =  "CCCCCCCC-AAAA-AAAA-AAAA-AAAAAAAAASLA";
    
    public AppExportTest(String name) {
        super(name);
    }
    
    public void testLoop_export() throws Exception {
        String appID = APP_ID;
        
        String url = APP_URL_PREFIX + appID + "?op=install" + "&uid=" + INSTALL_UID;
        ClientResource resource = createSecureClientResource(url);
        Representation rep = resource.get();
        String text = rep.getText();
        System.out.print("install... ");
        for (int i=1; i<=1; i++) {
            //setUp();
            url = APP_URL_PREFIX + appID + "?op=export" + "&uid=" + EXPORT_UID ;;
            resource = createSecureClientResource(url);
            rep = resource.post(null);
            text = rep.getText();
            System.out.println("loop: " + i);
            assertNotNull(text);
            //tearDown();
        }
        //setUp();
        url = APP_URL_PREFIX + appID + "?op=uninstall" + "&keepAppConf=false" + "&keepUserData=false" ;
        resource = createSecureClientResource(url);
        rep = resource.get();
        text = rep.getText();
        System.out.println("uninstall!");
        assertNotNull(text);
    }
    
}
